<template>
  <basic-container>
    <avue-crud
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        v-model="startForm">
      <template v-for="(column,index) in columns" :slot="column.prop" slot-scope="{type,size,row}">
        <component :is="column.columnComponent" :row="row" :rowKey="column.prop" :column="column" :key="row.id+':'+index"></component>
      </template>
      <template slot="menuLeft">
        <el-button type="primary" size="small" @click="startInstance">启动新实例</el-button>
      </template>
    </avue-crud>
    <start-config-dialog ref="startConfigDialog" @refresh="refreshChange"></start-config-dialog>
  </basic-container>
</template>

<script>
import startCrud from "@/mixins/start-crud.js"
import startConfigDialog from "@/views/start/activiti/instance/startConfigDialog";

export default startCrud({
  name: "index",
  components: {startConfigDialog},
  methods: {
    rowDel(row, index) {
      this.$prompt(`此操作将永久删除序号为【${index + 1}】的数据！ 请输入删除原因?`, '系统提示', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        inputType: "textarea",
        type: 'warning',
        inputErrorMessage: "删除原因不能为空",
        inputValidator: function (value) {
          return !!value;
        }
      }).then(({value}) => {
        return this.api[ 'deleteById'](row.id, {reason: value})
      }).then(res => {
        this.getList();
        this.$message.success('删除成功')
        if (this.rowDelAfter) this.rowDelAfter(row, index);
      })
    },
    startInstance() {
      this.$refs.startConfigDialog.show();
    }
  }
}, {name: "activiti/instance"})
</script>

<style scoped>

</style>
